package shujvjiegou.week3;

import java.util.Scanner;

public class Strut07 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        if(n == 1){
            System.out.print(arr[0]);
        }else {
            move(num,arr);
        }
    }
    public static void move(int num,int[] array){
        int turnnum = 0;
        int[] arr = new int[array.length];
        if (num % array.length != 0){
            turnnum = num % array.length;
            for (int i = 0; i < array.length; i++) {
                arr[i] = array[turnnum];
                turnnum++;
                if(turnnum == array.length){
                    turnnum = 0;
                }
            }
        }else{
            for (int i = 0; i < array.length; i++) {
                arr[i] = array[i];
            }
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}